#include "widget.h"
#include "ui_widget.h"


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    show111();
}

Widget::~Widget()
{
    delete ui;
}


#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <stdio.h>
using namespace cv;

#include <opencv2/highgui.hpp>

using namespace std;

int Widget::show111()
{
    VideoCapture capture;
    capture.open(0); //从摄像头读入视频 0表示从摄像头读入

    if (!capture.isOpened())
    {
        qDebug() << "can not open";
        //cin.get();
        return -1;
    }

//	namedWindow(name);

    while (1)
    {
        Mat cap;
        capture >> cap;
        if (!cap.empty()) //判断当前帧是否捕捉成功 **这步很重要
            cv::imshow("aa", cap);
        else
        {
            cout << "can not open";
            continue;
        }


        if(waitKey(3) == 'q')
            break; //延时30毫秒
    }

    return 0;

}
